#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include "errsys.h"

#define  BUFSIZE 1024

int main(int argc, char **argv)
{
	char cmd[BUFSIZE];
	FILE *fp;

	if(argc == 1){
		printf("%s program\n",argv[0]);
		exit(0);
	}

	strcpy( cmd, argv[1] );
//	strcat( cmd, " " );
//	strcat( cmd, argv[2] );

	fp = popen(cmd,"r");
	if(!fp)
		err_sys("popen error");
	while( fgets(cmd, BUFSIZE, fp) != NULL )
		if( !fputs( cmd, stdout ) )
		       err_sys("fputs error");

	if( ferror(fp) )
		err_sys("ferror");

	pclose(fp);

	return 0;
}

